from toee import *
from Co8 import *
from scripts import *
from utilities import *

def san_dialog( attachee, triggerer ):
	triggerer.turn_towards(attachee)
	attachee.turn_towards(triggerer)
	if (game.quests[15].state == qs_botched):
		triggerer.begin_dialog( attachee, 670 )
	elif (game.global_vars[900] == 4) and (game.global_flags[31] == 0):
		triggerer.begin_dialog( attachee, 660 )
	elif ( (game.global_vars[900] == 1) or (game.global_vars[900] == 2) or (game.global_vars[900] == 3) ) and (is_daytime() == 1):
		triggerer.begin_dialog( attachee, 640 )
	elif (game.global_vars[900] == 1) and (game.is_daytime() != 1):
		triggerer.begin_dialog( attachee, 310 )
	elif (game.global_vars[900] == 2) and (game.is_daytime() != 1):
		triggerer.begin_dialog( attachee, 410 )
	elif (game.global_vars[900] == 3) and (game.is_daytime() != 1):
		triggerer.begin_dialog( attachee, 510 )
	else:
		triggerer.begin_dialog( attachee, 1 )
	return SKIP_DEFAULT

def run_off( attachee, triggerer ):
	# loc = location_from_axis(427,406)
	# attachee.runoff(loc)
	attachee.runoff(attachee.location-3)
	return RUN_DEFAULT

def san_dying( attachee, triggerer ):
	if (game.party[0].reputation_has(9) == 0):
		game.party[0].reputation_add(9)
	return RUN_DEFAULT

def brawl( attachee, triggerer ):
	attachee.reaction_set(triggerer,-100)
	game.brawl( triggerer, attachee )
	return RUN_DEFAULT

def brawl_end( attachee, triggerer, brawl_state ):
	if (brawl_state == 0):
		attachee.reaction_set(triggerer,50)
		triggerer.begin_dialog( attachee, 300 )
	elif (brawl_state == 1):
		attachee.reaction_set(triggerer,50)
		triggerer.begin_dialog( attachee, 330 )
	else:
		attachee.reaction_set(triggerer,50)
		StopCombat(attachee, 1)
		triggerer.begin_dialog( attachee, 400 )
	return RUN_DEFAULT
